Release 10.1A: OpenEdge Development:
.NET Open Clients


Defining the schema for a ProDataSet parameter

Defining the schema for a Progress 4GL ProDataSet (DATASET or DATASET-HANDLE) parameter is a multi-step process.

To define the schema for a ProDataSet parameter:

  1. If the parameter is for input or input-output, define an ADO.NET DataSet to hold the parameter value.
  2. Define a ProDataSetMetaData object to specify its schema.
  3. Define the temp-tables for the ProDataSetMetaData object.
  4. Define the data-relations for the ProDataSetMetaData object.
  5. Add the ProDataSetMetaData object and the DataSet (if applicable) as a ProDataSet parameter to your ParamArray object using the appropriate set parameter method.
Defining a ProDataSetMetaData object

For each ProDataSet parameter you must define a Progress.Open4GL.Proxy.ProDataSetMetaData object. You use this object to specify the schema for the ProDataSet when you set the DATASET or DATASET-HANDLE parameter in the ParamArray object. You can create an instance of this object using the following constructor:

Syntax
public ProDataSetMetaData (string proDataSetName, string strongTypeName) 

proDataSetName

Specifies the ProDataSet name in the 4GL.

strongTypeName

Specifies the type name for a strongly-typed ADO.NET DataSet, or null.

Defining the temp-tables for the ProDataSetMetaData object

You must define the meta data for each temp-table contained by the ProDataSetMetaData. For more information, see the following sections:

You can then add the temp-table meta data (TempTableMetaData) to the ProDataSetMetaData object using the following ProDataSetMetaData method:

Syntax
public void AddDataTable (TempTableMetaData dtMetaData) 

dtMetaData

Specifies the meta data for a temp-table.

Defining the data-relations for the ProDataSetMetaData object

You must define any data-relations that are defined for the 4GL ProDataSet using Progress.Open4GL.Proxy.ProDataRelationMetaData objects. You can create a ProDataRelationMetaData object for each data-relation between a parent and child temp-table using the following constructor:

Syntax
public ProDataRelationMetaData (string dataRelationName, int parentIx,  
                                int childIx, int numPairs, string pairsList) 

dataRelationName

Specifies the name of the ProDataRelationMetaData object.

parentIx

Specifies a 0-based index to a parent temp-table (ADO.NET DataTable) that corresponds to the order in which you have added the TempTableMetaData to the ProDataSetMetaData using the ProDataSetMetaData AddDataTable() method. If you have the ADO.NET DataSet for the ProDataSet, you can also use the ADO.NET DataSet.Tables property to identify the order for this index value.

childIx

Specifies a 0-based index to a child temp-table (ADO.NET DataTable) that corresponds to the order in which you have added the TempTableMetaData to the ProDataSetMetaData using the ProDataSetMetaData AddDataTable() method. If you have the ADO.NET DataSet for the ProDataSet, you can also use the ADO.NET DataSet.Tables property to identify the order for this index value.

numPairs

Specifies the number of column property pairs (key field pairs) that represent this relationship. This allows multiple fields to represent a key relationship between the parent and child temp-table.

pairsList

Specifies a string containing a comma-separated list of field names. The list consists of numPairs field pairs, where the child temp-table field name for each pair is followed by its matching parent temp-table field name. The data types of the named child and parent temp-table field pairs must be comparable.

Note: For the equivalent ProDataRelationMetaData() constructor in the Java OpenAPI, the order of child and parent field names in the pairsList parameter is reversed. For more information, see OpenEdge Development: Java Open Clients .

You can add each data-relation definition to the ProDataSetMetaData object using the following method:

Syntax
public void AddDataRelation(ProDataRelationMetaData drMetaData) 

drMetaData

Specifies a data-relation to include in the ProDataSetMetaData object.

Adding the ProDataSetMetaData object with its DataSet as a ProDataSet parameter

Add the ProDataSetMetaData object together with the ADO.NET DataSet it describes by passing them as parameters of the AddDataset() or AddDatasetHandle() method that you use to add the ProDataSet parameter to the ParamArray object. For more information, see the "DATASET and DATASET-HANDLE" section.

Example 8–2 adds a temp-table parameter defined with no indexes:

Example 8–2: Sample OpenAPI fragment setting a ProDataSet parameter
// Create the ParamArray 
ParamArray parms = new ParamArray(1); 
//Create DataSet 
DataSet proDataSet = new DataSet(); 
... 
// Create the ProDataSetMetaData 
ProDataSetMetaData dsMetaData = new ProDataSetMetaData 
             ("dsCustOrd", "ProDataSetTest.StrongTypesNS.dsCustOrdDataSet"); 
// Create the TempTableMetaData for the Customer table 
TempTableMetaData ttCustMD = new TempTableMetaData 
                         ("ttCust",  
                          "ttCustDataTable",  
                          3, false, , 0, null, null, null); 
ttCustMD.SetFieldMetaData 
             (1, "CustNum",  0, Parameter.PRO_INTEGER,  0, 0); 
ttCustMD.SetFieldMetaData 
             (2, "Name",     0, Parameter.PRO_CHARACTER 1, 0); 
ttCustMD.SetFieldMetaData 
             (3, "SalesRep", 0, Parameter.PRO_CHARACTER 2, 0); 
// Create the TempTableMetaData for the Order table 
TempTableMetaData ttOrderMD = new TempTableMetaData 
                          ("OrderDetails", 
                           "OrderProxy.StrongTypesNS.OrderDetailsDataTable",  
                           6, false, , 0, null, null, null); 
ttOrderMD.SetFieldMetaData 
             (1, "OrderNum",     0, Parameter.PRO_INTEGER,  0, 0); 
ttOrderMD.SetFieldMetaData 
             (2, "SalesRep",     0, Parameter.PRO_CHARACTER 1, 0); 
ttOrderMD.SetFieldMetaData 
             (3, "OrderDate",    0, Parameter.PRO_DATE      2, 0); 
ttOrderMD.SetFieldMetaData 
             (4, "ShipDate",     0, Parameter.PRO_DATE      3, 0); 
ttOrderMD.SetFieldMetaData 
             (5, "TotalDollars", 0, Parameter.PRO_DECIMAL   4, 0); 
ttOrderMD.SetFieldMetaData 
             (6, "OrderStatus",  0, Parameter.PRO_CHARACTER 5, 0); 
// Add the tables to the DataSet meta data 
dsMetaData.AddDataTable(ttCustMD); 
dsMetaData.AddDataTable(ttOrderMD); 
// Create and add the relations to the DataSet meta data 
ProDataRelationMetaData relation = new ProDataRelationMetaData 
                              ("custNum", 1, 0, 1, "CustNum,CustNum",  null); 
dsMetaData.AddDataRelation(relation); 
parms.AddDataset(0, proDataSet, ParamArrayMode.OUTPUT, dsMetaData); 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095